var utils = require("../utils/utils");
var ocr_utils = require("../utils/ocr_utils");
var ad = require("./ad");
var point_map = require("./pointMap");
var read = {
  go_page_from_home() {
    var logger = utils.create_logger("read go_page_from_home: ");
    logger("");
    this.init();
  },
  init() {
    console.log("read init: ");
    this.run();
  },
  run() {
    console.show();
    var logger = utils.create_logger("read run:");
    logger("");
    var times = 1 + random(0, 1);
    logger("将看--" + times + "--个视频");
    for (var index = 0; index < times; index++) {
      utils.swipe(1 / 2, 8 / 10, 1 / 2, 2 / 10);
      sleep(utils.get_random_interval(2, 0, 1, 1000));
      if (ocr_utils.screen_exists_text_one(["直播间", "点击进入"], false)) {
        logger("找到--xxxxxx--，直接跳过");
        index = index - 1;
        continue;
      }
      var interval = utils.get_random_interval(2, 0, 5, 1000);
      logger(
        "准备开始看第--" +
          (index + 1) +
          "--个视频，将耗时--" +
          interval / 1000 +
          "--秒"
      );
      sleep(interval);
      logger("已看完第--" + (index + 1) + "--个视频，下面开始滑动");
    }
    console.hide();
    sleep(utils.get_random_interval(1, 0, 1, 1000));
    this.after();
  },
  after() {
    console.log("read after");
    this.next();
  },
  next() {
    console.log("read next");
  },
};
module.exports = read;
